using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Web.UI.DataVisualization.Charting;
using System.Data.Common;
using System.Management;
using System.Text;
using System.Net.Mail;

public partial class Reports : System.Web.UI.Page
{
    Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase("Application_Data");

    protected void Page_Load(object sender, EventArgs e)
    {        
        if (!IsPostBack)
        {
            String strInstanceCount = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(COUNT(InstanceName),'3','i,',0) FROM Instance").ToString();
            String strDatabaseCount = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(COUNT(DatabaseName),'3','i,',0) FROM [Database]").ToString();
            String strSumSpaceAllocated = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(SUM(TotalSizeMB),'3','i,',0) FROM [Database]").ToString();
            String strSUMSpaceUsed = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(SUM(DataSpaceUsedMB),'3','i,',0) FROM [Database]").ToString();
            String strSumDataSizeMB = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(SUM(DataSizeMB),'3','i,',0) FROM [Database]").ToString();
            String strSUMLogSizeMB = db.ExecuteScalar(CommandType.Text, "SELECT dbo.FormatNumber(SUM(LogSizeMB),'3','i,',0) FROM [Database]").ToString();
                 
            this.lblInstanceCount.Text = strInstanceCount;
            this.lblDatabaseCount.Text = strDatabaseCount;
            this.lblSpaceAllocated.Text = strSumSpaceAllocated;
            this.lblSpaceUsed.Text = strSUMSpaceUsed;
            this.lblDataSizeMB.Text = strSumDataSizeMB;
            this.lblLogSizeMB.Text = strSUMLogSizeMB;

            string sqlQuery1 = "DECLARE @t TABLE (TimeFrame VARCHAR(50),TotalSizeMB INT,DataSizeMB INT,LogSizeMB INT,DataSpaceUsedMB INT) " +
                               "INSERT INTO @t SELECT 'Today',SUM(TotalSizeMB) AS TotalSizeMB,SUM(DataSizeMB) AS DataSizeMB,SUM(LogSizeMB) AS LogSizeMB,SUM(DataSpaceUsedMB) AS DataSpaceUsedMB FROM [Database] " +
                               "INSERT INTO @t SELECT '30 Days Ago',SUM(TotalSizeMBDay30) AS TotalSizeMB,SUM(DataSizeMBDay30) AS DataSizeMB,SUM(LogSizeMBDay30) AS LogSizeMB,SUM(DataSpaceUsedMBDay30) AS DataSpaceUsedMB FROM [Database] " +
                               "INSERT INTO @t SELECT '12 Months Ago', SUM(TotalSizeMBMonth12) AS TotalSizeMB,SUM(DataSizeMBMonth12) AS DataSizeMB,SUM(LogSizeMBMonth12) AS LogSizeMB,SUM(DataSpaceUsedMBMonth12) AS DataSpaceUsedMB FROM [Database] " +
                               "INSERT INTO @t SELECT '2 Years ago', SUM(TotalSizeMBYear02) AS TotalSizeMB,SUM(DataSizeMBYear02) AS DataSizeMB,SUM(LogSizeMBYear02) AS LogSizeMB,SUM(DataSpaceUsedMBYear02) AS DataSpaceUsedMB FROM [Database] " +
                               "INSERT INTO @t SELECT '3 Years ago', SUM(TotalSizeMBYear03) AS TotalSizeMB,SUM(DataSizeMBYear03) AS DataSizeMB,SUM(LogSizeMBYear03) AS LogSizeMB,SUM(DataSpaceUsedMBYear03) AS DataSpaceUsedMB FROM [Database] " +
                               "INSERT INTO @t SELECT '4 Years ago', SUM(TotalSizeMBYear04) AS TotalSizeMB,SUM(DataSizeMBYear04) AS DataSizeMB,SUM(LogSizeMBYear04) AS LogSizeMB,SUM(DataSpaceUsedMBYear04) AS DataSpaceUsedMB FROM [Database] " +
                               "SELECT TimeFrame,dbo.FormatNumber(TotalSizeMB,'3','i,',0) AS TotalSizeMB,dbo.FormatNumber(DataSizeMB,'3','i,',0) AS DataSizeMB,dbo.FormatNumber(LogSizeMB,'3','i,',0)AS LogSizeMB,dbo.FormatNumber(DataSpaceUsedMB,'3','i,',0) AS DataSpaceUsedMB FROM @t";

            DataSet ds1 = db.ExecuteDataSet(CommandType.Text, sqlQuery1);
            gv1.DataSource = ds1;
            gv1.DataBind();

            string sqlQuery3 = "SELECT TOP(10) InstanceName,DatabaseName, dbo.FormatNumber(TotalSizeMB,'3','i,',0) AS 'TotalSize(MB)' FROM [Database] with (nolock) Order by TotalSizeMB DESC";
            DataSet ds3 = db.ExecuteDataSet(CommandType.Text, sqlQuery3);
            gvTop10LargestDatabase.DataSource = ds3;
            gvTop10LargestDatabase.DataBind();

            string sqlQuery5 = "SELECT TOP(10) InstanceName,DatabaseName,dbo.FormatNumber(DataSpaceUsedMBDay30,'3','i,',0) as 'Last Month',dbo.FormatNumber(DataSpaceUsedMBDay01,'3','i,',0) AS 'Today',dbo.FormatNumber((DataSpaceUsedMBDay01-DataSpaceUsedMBDay30),'3','i,',0) AS GrowthMB FROM [Database] WHERE DataSpaceUsedMBDay01 IS NOT NULL AND DataSpaceUsedMBDay30 IS NOT NULL AND DatabaseName NOT IN ('master','model','tempdb','msdb') ORDER BY (DataSpaceUsedMBDay30-DataSpaceUsedMBDay01)";
            DataSet ds5 = db.ExecuteDataSet(CommandType.Text, sqlQuery5);
            this.gvFastestGrowthMonth.DataSource = ds5;
            this.gvFastestGrowthMonth.DataBind();

            string sqlQuery6 = "SELECT TOP(10) InstanceName,DatabaseName,dbo.FormatNumber(DataSpaceUsedMBMonth12,'3','i,',0) as 'Last Year',dbo.FormatNumber(DataSpaceUsedMBDay01,'3','i,',0) AS 'Today',dbo.FormatNumber((DataSpaceUsedMBDay01-DataSpaceUsedMBMonth12),'3','i,',0) AS GrowthMB FROM [Database] WHERE DataSpaceUsedMBDay01 IS NOT NULL AND DataSpaceUsedMBMonth12 IS NOT NULL AND DatabaseName NOT IN ('master','model','tempdb','msdb') ORDER BY (DataSpaceUsedMBMonth12-DataSpaceUsedMBDay01)";
            DataSet ds6 = db.ExecuteDataSet(CommandType.Text, sqlQuery6);
            this.gvFastestGrowthYear.DataSource = ds6;
            this.gvFastestGrowthYear.DataBind();

            //DatabaseTrending Charts
            string qChtYear = "DECLARE @t TABLE (ByYear VARCHAR(10),TotalSizeMB INT,DataSizeMB INT,LogSizeMB INT,DataSpaceUsedMB INT) " +
                              "INSERT INTO @t SELECT '01', SUM(TotalSizeMBYear01),SUM(DataSizeMBYear01),SUM(LogSizeMBYear01),SUM(DataSpaceUsedMBYear01) FROM [Database] " +
                              "INSERT INTO @t SELECT '02', SUM(TotalSizeMBYear02),SUM(DataSizeMBYear02),SUM(LogSizeMBYear02),SUM(DataSpaceUsedMBYear02) FROM [Database] " +
                              "INSERT INTO @t SELECT '03', SUM(TotalSizeMBYear03),SUM(DataSizeMBYear03),SUM(LogSizeMBYear03),SUM(DataSpaceUsedMBYear03) FROM [Database] " +
                              "INSERT INTO @t SELECT '04', SUM(TotalSizeMBYear04),SUM(DataSizeMBYear04),SUM(LogSizeMBYear04),SUM(DataSpaceUsedMBYear04) FROM [Database] " +
                              "SELECT * FROM @t ORDER BY ByYear DESC";

            DataSet dsChtYear = db.ExecuteDataSet(CommandType.Text, qChtYear);
            chtYear.DataSource = dsChtYear;

            chtYear.Titles.Add("Last 4 Years");

            chtYear.Series.Add("TotalSizeMB");
            chtYear.Series.Add("DataSizeMB");
            chtYear.Series.Add("LogSizeMB");
            chtYear.Series.Add("DataSpaceUsedMB");

            chtYear.Series["TotalSizeMB"].ChartType = SeriesChartType.Line;
            chtYear.Series["TotalSizeMB"].BorderWidth = 2;
            chtYear.Series["TotalSizeMB"].Color = System.Drawing.Color.Red;
            chtYear.Series["DataSizeMB"].ChartType = SeriesChartType.Line;
            chtYear.Series["DataSizeMB"].BorderWidth = 2;
            chtYear.Series["DataSizeMB"].Color = System.Drawing.Color.Blue;
            chtYear.Series["LogSizeMB"].ChartType = SeriesChartType.Line;
            chtYear.Series["LogSizeMB"].BorderWidth = 2;
            chtYear.Series["LogSizeMB"].Color = System.Drawing.Color.Green;
            chtYear.Series["DataSpaceUsedMB"].ChartType = SeriesChartType.Line;
            chtYear.Series["DataSpaceUsedMB"].BorderWidth = 2;
            chtYear.Series["DataSpaceUsedMB"].Color = System.Drawing.Color.Purple;

            chtYear.Series["TotalSizeMB"].XValueMember = "ByYear";
            chtYear.Series["TotalSizeMB"].YValueMembers = "TotalSizeMB";
            chtYear.Series["DataSizeMB"].XValueMember = "ByYear";
            chtYear.Series["DataSizeMB"].YValueMembers = "DataSizeMB";
            chtYear.Series["LogSizeMB"].XValueMember = "ByYear";
            chtYear.Series["LogSizeMB"].YValueMembers = "LogSizeMB";
            chtYear.Series["DataSpaceUsedMB"].XValueMember = "ByYear";
            chtYear.Series["DataSpaceUsedMB"].YValueMembers = "DataSpaceUsedMB";
            chtYear.DataBind();

            //Month
            string qChtMonth = "DECLARE @t TABLE (ByMonth VARCHAR(10),TotalSizeMB INT,DataSizeMB INT,LogSizeMB INT,DataSpaceUsedMB INT) " +
                               "INSERT INTO @t SELECT '01', SUM(TotalSizeMBMonth01),SUM(DataSizeMBMonth01),SUM(LogSizeMBMonth01),SUM(DataSpaceUsedMBMonth01) FROM [Database] " +
                               "INSERT INTO @t SELECT '02', SUM(TotalSizeMBMonth02),SUM(DataSizeMBMonth02),SUM(LogSizeMBMonth02),SUM(DataSpaceUsedMBMonth02) FROM [Database] " +
                               "INSERT INTO @t SELECT '03', SUM(TotalSizeMBMonth03),SUM(DataSizeMBMonth03),SUM(LogSizeMBMonth03),SUM(DataSpaceUsedMBMonth03) FROM [Database] " +
                               "INSERT INTO @t SELECT '04', SUM(TotalSizeMBMonth04),SUM(DataSizeMBMonth04),SUM(LogSizeMBMonth04),SUM(DataSpaceUsedMBMonth04) FROM [Database] " +
                               "INSERT INTO @t SELECT '05', SUM(TotalSizeMBMonth05),SUM(DataSizeMBMonth05),SUM(LogSizeMBMonth05),SUM(DataSpaceUsedMBMonth05) FROM [Database] " +
                               "INSERT INTO @t SELECT '06', SUM(TotalSizeMBMonth06),SUM(DataSizeMBMonth06),SUM(LogSizeMBMonth06),SUM(DataSpaceUsedMBMonth06) FROM [Database] " +
                               "INSERT INTO @t SELECT '07', SUM(TotalSizeMBMonth07),SUM(DataSizeMBMonth07),SUM(LogSizeMBMonth07),SUM(DataSpaceUsedMBMonth07) FROM [Database] " +
                               "INSERT INTO @t SELECT '08', SUM(TotalSizeMBMonth08),SUM(DataSizeMBMonth08),SUM(LogSizeMBMonth08),SUM(DataSpaceUsedMBMonth08) FROM [Database] " +
                               "INSERT INTO @t SELECT '09', SUM(TotalSizeMBMonth09),SUM(DataSizeMBMonth09),SUM(LogSizeMBMonth09),SUM(DataSpaceUsedMBMonth09) FROM [Database] " +
                               "INSERT INTO @t SELECT '10', SUM(TotalSizeMBMonth10),SUM(DataSizeMBMonth10),SUM(LogSizeMBMonth10),SUM(DataSpaceUsedMBMonth10) FROM [Database] " +
                               "INSERT INTO @t SELECT '11', SUM(TotalSizeMBMonth11),SUM(DataSizeMBMonth11),SUM(LogSizeMBMonth11),SUM(DataSpaceUsedMBMonth11) FROM [Database] " +
                               "INSERT INTO @t SELECT '12', SUM(TotalSizeMBMonth12),SUM(DataSizeMBMonth12),SUM(LogSizeMBMonth12),SUM(DataSpaceUsedMBMonth12) FROM [Database] " +
                               "SELECT * FROM @t ORDER BY ByMonth DESC";

            DataSet dsChtMonth = db.ExecuteDataSet(CommandType.Text, qChtMonth);
            chtMonth.DataSource = dsChtMonth;

            chtMonth.Titles.Add("Last 12 Months");

            chtMonth.Series.Add("TotalSizeMB");
            chtMonth.Series.Add("DataSizeMB");
            chtMonth.Series.Add("LogSizeMB");
            chtMonth.Series.Add("DataSpaceUsedMB");

            chtMonth.Series["TotalSizeMB"].ChartType = SeriesChartType.Line;
            chtMonth.Series["TotalSizeMB"].BorderWidth = 2;
            chtMonth.Series["TotalSizeMB"].Color = System.Drawing.Color.Red;
            chtMonth.Series["DataSizeMB"].ChartType = SeriesChartType.Line;
            chtMonth.Series["DataSizeMB"].BorderWidth = 2;
            chtMonth.Series["DataSizeMB"].Color = System.Drawing.Color.Blue;
            chtMonth.Series["LogSizeMB"].ChartType = SeriesChartType.Line;
            chtMonth.Series["LogSizeMB"].BorderWidth = 2;
            chtMonth.Series["LogSizeMB"].Color = System.Drawing.Color.Green;
            chtMonth.Series["DataSpaceUsedMB"].ChartType = SeriesChartType.Line;
            chtMonth.Series["DataSpaceUsedMB"].BorderWidth = 2;
            chtMonth.Series["DataSpaceUsedMB"].Color = System.Drawing.Color.Purple;

            chtMonth.Series["TotalSizeMB"].XValueMember = "ByMonth";
            chtMonth.Series["TotalSizeMB"].YValueMembers = "TotalSizeMB";
            chtMonth.Series["DataSizeMB"].XValueMember = "ByMonth";
            chtMonth.Series["DataSizeMB"].YValueMembers = "DataSizeMB";
            chtMonth.Series["LogSizeMB"].XValueMember = "ByMonth";
            chtMonth.Series["LogSizeMB"].YValueMembers = "LogSizeMB";
            chtMonth.Series["DataSpaceUsedMB"].XValueMember = "ByMonth";
            chtMonth.Series["DataSpaceUsedMB"].YValueMembers = "DataSpaceUsedMB";
            chtMonth.DataBind();

            //Chart Day
            string qChtDay = "DECLARE @t TABLE (ByDay VARCHAR(10),TotalSizeMB INT,DataSizeMB INT,LogSizeMB INT,DataSpaceUsedMB INT) " +
                             "INSERT INTO @t SELECT '01', SUM(TotalSizeMBDay01),SUM(DataSizeMBDay01),SUM(LogSizeMBDay01),SUM(DataSpaceUsedMBDay01) FROM [Database] " +
                             "INSERT INTO @t SELECT '02', SUM(TotalSizeMBDay02),SUM(DataSizeMBDay02),SUM(LogSizeMBDay02),SUM(DataSpaceUsedMBDay02) FROM [Database] " +
                             "INSERT INTO @t SELECT '03', SUM(TotalSizeMBDay03),SUM(DataSizeMBDay03),SUM(LogSizeMBDay03),SUM(DataSpaceUsedMBDay03) FROM [Database] " +
                             "INSERT INTO @t SELECT '04', SUM(TotalSizeMBDay04),SUM(DataSizeMBDay04),SUM(LogSizeMBDay04),SUM(DataSpaceUsedMBDay04) FROM [Database] " +
                             "INSERT INTO @t SELECT '05', SUM(TotalSizeMBDay05),SUM(DataSizeMBDay05),SUM(LogSizeMBDay05),SUM(DataSpaceUsedMBDay05) FROM [Database] " +
                             "INSERT INTO @t SELECT '06', SUM(TotalSizeMBDay06),SUM(DataSizeMBDay06),SUM(LogSizeMBDay06),SUM(DataSpaceUsedMBDay06) FROM [Database] " +
                             "INSERT INTO @t SELECT '07', SUM(TotalSizeMBDay07),SUM(DataSizeMBDay07),SUM(LogSizeMBDay07),SUM(DataSpaceUsedMBDay07) FROM [Database] " +
                             "INSERT INTO @t SELECT '08', SUM(TotalSizeMBDay08),SUM(DataSizeMBDay08),SUM(LogSizeMBDay08),SUM(DataSpaceUsedMBDay08) FROM [Database] " +
                             "INSERT INTO @t SELECT '09', SUM(TotalSizeMBDay09),SUM(DataSizeMBDay09),SUM(LogSizeMBDay09),SUM(DataSpaceUsedMBDay09) FROM [Database] " +
                             "INSERT INTO @t SELECT '10', SUM(TotalSizeMBDay10),SUM(DataSizeMBDay10),SUM(LogSizeMBDay10),SUM(DataSpaceUsedMBDay10) FROM [Database] " +
                             "INSERT INTO @t SELECT '11', SUM(TotalSizeMBDay11),SUM(DataSizeMBDay11),SUM(LogSizeMBDay11),SUM(DataSpaceUsedMBDay11) FROM [Database] " +
                             "INSERT INTO @t SELECT '12', SUM(TotalSizeMBDay12),SUM(DataSizeMBDay12),SUM(LogSizeMBDay12),SUM(DataSpaceUsedMBDay12) FROM [Database] " +
                             "INSERT INTO @t SELECT '13', SUM(TotalSizeMBDay13),SUM(DataSizeMBDay13),SUM(LogSizeMBDay13),SUM(DataSpaceUsedMBDay13) FROM [Database] " +
                             "INSERT INTO @t SELECT '14', SUM(TotalSizeMBDay14),SUM(DataSizeMBDay14),SUM(LogSizeMBDay14),SUM(DataSpaceUsedMBDay14) FROM [Database] " +
                             "INSERT INTO @t SELECT '15', SUM(TotalSizeMBDay15),SUM(DataSizeMBDay15),SUM(LogSizeMBDay15),SUM(DataSpaceUsedMBDay15) FROM [Database] " +
                             "INSERT INTO @t SELECT '16', SUM(TotalSizeMBDay16),SUM(DataSizeMBDay16),SUM(LogSizeMBDay16),SUM(DataSpaceUsedMBDay16) FROM [Database] " +
                             "INSERT INTO @t SELECT '17', SUM(TotalSizeMBDay17),SUM(DataSizeMBDay17),SUM(LogSizeMBDay17),SUM(DataSpaceUsedMBDay17) FROM [Database] " +
                             "INSERT INTO @t SELECT '18', SUM(TotalSizeMBDay18),SUM(DataSizeMBDay18),SUM(LogSizeMBDay18),SUM(DataSpaceUsedMBDay18) FROM [Database] " +
                             "INSERT INTO @t SELECT '19', SUM(TotalSizeMBDay19),SUM(DataSizeMBDay19),SUM(LogSizeMBDay19),SUM(DataSpaceUsedMBDay19) FROM [Database] " +
                             "INSERT INTO @t SELECT '20', SUM(TotalSizeMBDay20),SUM(DataSizeMBDay20),SUM(LogSizeMBDay20),SUM(DataSpaceUsedMBDay20) FROM [Database] " +
                             "INSERT INTO @t SELECT '21', SUM(TotalSizeMBDay21),SUM(DataSizeMBDay21),SUM(LogSizeMBDay21),SUM(DataSpaceUsedMBDay21) FROM [Database] " +
                             "INSERT INTO @t SELECT '22', SUM(TotalSizeMBDay22),SUM(DataSizeMBDay22),SUM(LogSizeMBDay22),SUM(DataSpaceUsedMBDay22) FROM [Database] " +
                             "INSERT INTO @t SELECT '23', SUM(TotalSizeMBDay23),SUM(DataSizeMBDay23),SUM(LogSizeMBDay23),SUM(DataSpaceUsedMBDay23) FROM [Database] " +
                             "INSERT INTO @t SELECT '24', SUM(TotalSizeMBDay24),SUM(DataSizeMBDay24),SUM(LogSizeMBDay24),SUM(DataSpaceUsedMBDay24) FROM [Database] " +
                             "INSERT INTO @t SELECT '25', SUM(TotalSizeMBDay25),SUM(DataSizeMBDay25),SUM(LogSizeMBDay25),SUM(DataSpaceUsedMBDay25) FROM [Database] " +
                             "INSERT INTO @t SELECT '26', SUM(TotalSizeMBDay26),SUM(DataSizeMBDay26),SUM(LogSizeMBDay26),SUM(DataSpaceUsedMBDay26) FROM [Database] " +
                             "INSERT INTO @t SELECT '27', SUM(TotalSizeMBDay27),SUM(DataSizeMBDay27),SUM(LogSizeMBDay27),SUM(DataSpaceUsedMBDay27) FROM [Database] " +
                             "INSERT INTO @t SELECT '28', SUM(TotalSizeMBDay28),SUM(DataSizeMBDay28),SUM(LogSizeMBDay28),SUM(DataSpaceUsedMBDay28) FROM [Database] " +
                             "INSERT INTO @t SELECT '29', SUM(TotalSizeMBDay29),SUM(DataSizeMBDay29),SUM(LogSizeMBDay29),SUM(DataSpaceUsedMBDay29) FROM [Database] " +
                             "INSERT INTO @t SELECT '30', SUM(TotalSizeMBDay30),SUM(DataSizeMBDay30),SUM(LogSizeMBDay30),SUM(DataSpaceUsedMBDay30) FROM [Database] " +
                             "SELECT * FROM @t ORDER BY ByDay DESC";

            DataSet dsChtDay = db.ExecuteDataSet(CommandType.Text, qChtDay);
            chtDay.DataSource = dsChtDay;

            chtDay.Titles.Add("Last 30 Days");

            chtDay.Legends.Add("DayLegend");
            chtDay.Legends["DayLegend"].BorderColor = System.Drawing.Color.Black;

            chtDay.Series.Add("TotalSizeMB");
            chtDay.Series.Add("DataSizeMB");
            chtDay.Series.Add("LogSizeMB");
            chtDay.Series.Add("DataSpaceUsedMB");

            chtDay.Series["TotalSizeMB"].ChartType = SeriesChartType.Line;
            chtDay.Series["TotalSizeMB"].BorderWidth = 2;
            chtDay.Series["TotalSizeMB"].Color = System.Drawing.Color.Red;
            chtDay.Series["DataSizeMB"].ChartType = SeriesChartType.Line;
            chtDay.Series["DataSizeMB"].BorderWidth = 2;
            chtDay.Series["DataSizeMB"].Color = System.Drawing.Color.Blue;
            chtDay.Series["LogSizeMB"].ChartType = SeriesChartType.Line;
            chtDay.Series["LogSizeMB"].BorderWidth = 2;
            chtDay.Series["LogSizeMB"].Color = System.Drawing.Color.Green;
            chtDay.Series["DataSpaceUsedMB"].ChartType = SeriesChartType.Line;
            chtDay.Series["DataSpaceUsedMB"].BorderWidth = 2;
            chtDay.Series["DataSpaceUsedMB"].Color = System.Drawing.Color.Purple;

            chtDay.Series["TotalSizeMB"].XValueMember = "ByDay";
            chtDay.Series["TotalSizeMB"].YValueMembers = "TotalSizeMB";
            chtDay.Series["DataSizeMB"].XValueMember = "ByDay";
            chtDay.Series["DataSizeMB"].YValueMembers = "DataSizeMB";
            chtDay.Series["LogSizeMB"].XValueMember = "ByDay";
            chtDay.Series["LogSizeMB"].YValueMembers = "LogSizeMB";
            chtDay.Series["DataSpaceUsedMB"].XValueMember = "ByDay";
            chtDay.Series["DataSpaceUsedMB"].YValueMembers = "DataSpaceUsedMB";
            chtDay.DataBind();                           
        }      
    }
}